/**
 * File: GenericFollowupPipeline.java
 * Created by: mhaimel
 * Created on: 27 Aug 2009
 * CVS:  $Id: GenericFollowupPipeline.java,v 1.2 2009/10/09 14:42:35 mhaimel Exp $
 */
package uk.ac.ebi.curtain;

import java.util.Arrays;

import uk.ac.ebi.curtain.configuration.ArumentHelper;
import uk.ac.ebi.curtain.configuration.CurtainInputArguments;
import uk.ac.ebi.curtain.configuration.impl.SimpleCurtainInputArgumentParser;

/**
 * @author mhaimel
 *
 */
public class GenericFollowupPipeline extends AbstractPipelineBootstrapper {
	
	public static void main(String[] args) {
		GenericFollowupPipeline pipeline = new GenericFollowupPipeline();
		pipeline.boot(args);
	}

	private String controllerType;
	
	@Override
	public String printHelp() {
		StringBuilder sb = new StringBuilder();
		sb.append(super.printHelp());
		sb.append("\n===================================\n\nCurtain Parameters:\n----------------------\n");
		sb.append(SimpleCurtainInputArgumentParser.getHelpDescr());
		return sb.toString() ;
	}
	
	@Override
	protected CurtainInputArguments parseArguments(String[] args) {
		if(args.length < 2){
			System.err.println(printHelp());
			System.exit(1);
		}
		ArumentHelper helper = new ArumentHelper();
		new SimpleCurtainInputArgumentParser().getArguments(args, helper, false);
		CurtainInputArguments arguments = helper.getCurtainArg();
		String controllerType = helper.getPipelineType();
		System.setProperty("curtain.pipeline.type", controllerType);

		getLog().info("Command submitted: " + Arrays.toString(args));
		
		this.setType(controllerType);
		return arguments;
	}

	private void setType(String controllerType) {
		this.controllerType = controllerType;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected boolean deleteWorkingDirecotry() {
		return false;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected String getControllerType() {
		return controllerType;
	}
}
